package com.fanbuchi;

import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Property;
import de.greenrobot.daogenerator.Schema;
import de.greenrobot.daogenerator.ToMany;

/**
 * @title greendaoSQLite 代码生成
 * @title 推送消息存储
 * @title 临时发送消息存储
 * @title 临时缓存网络数据
 */
public class PushMsgGenerator {

    public static void main(String[] args) throws Exception {
        Schema schema = new Schema(1,"com.fanbuchi.fukua.greendao");
        addNote(schema);
       // addCustomerOrder(schema);

        new DaoGenerator().generateAll(schema, "./greendao/src-gen");
    }


    /**
     * @title 编辑发布存储
     * @title 文字版
     * @title md 图文/音视频版
     * @param schema
     */
    private static void addNote(Schema schema) {
        Entity note = schema.addEntity("Note");
        note.addIdProperty();
        note.addStringProperty("userName").notNull();
        note.addStringProperty("nickName").notNull();
        note.addDateProperty("editContent");
        note.addDateProperty("editTime").notNull();

    }

    private static void addCustomerOrder(Schema schema) {
        Entity customer = schema.addEntity("Customer");
        customer.addIdProperty();
        customer.addStringProperty("name").notNull();

        Entity order = schema.addEntity("Order");
        order.setTableName("ORDERS"); // "ORDER" is a reserved keyword
        order.addIdProperty();
        Property orderDate = order.addDateProperty("date").getProperty();
        Property customerId = order.addLongProperty("customerId").notNull().getProperty();
        order.addToOne(customer, customerId);

        ToMany customerToOrders = customer.addToMany(order, customerId);
        customerToOrders.setName("orders");
        customerToOrders.orderAsc(orderDate);
    }


}
